Skip to content

fix: hot wallet allowed to init perp/spot market#2168

Merged
lowkeynicc merged 1 commit intomasterfrom
nick/fix-init-perp-mkt-signer
Mar 26, 2026
Merged

fix: hot wallet allowed to init perp/spot market#2168
lowkeynicc merged 1 commit intomasterfrom
nick/fix-init-perp-mkt-signer

Conversation

@lowkeynicc
Copy link
Copy Markdown
Contributor

@lowkeynicc lowkeynicc commented Mar 25, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Added option to use hot wallet as the admin account for market initialization, with configurable fallback behavior to alternative account sources.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Walkthrough

Updated instruction account mappings in adminClient.ts to conditionally select the admin account for initializeSpotMarket and initializePerpMarket instructions. When a useHotWalletAdmin flag is enabled, the admin account is set to wallet.publicKey directly; otherwise, it uses subscription-based logic to choose between getStateAccount().admin and wallet.publicKey.

Changes

Cohort / File(s) Summary
Admin Account Selection Logic
sdk/src/adminClient.ts
Modified accounts.admin assignment for initializeSpotMarket and initializePerpMarket instructions to use useHotWalletAdmin flag for conditional account selection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A flag now guides our admin's way,
Hot wallet or the state's say,
Which path to take, we now can choose,
No more a single logic fuse! 🔀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: allowing hot wallets to initialize perp/spot markets by adding logic to use a hot wallet admin when appropriate.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
sdk/src/adminClient.ts (1)

260-264: Extract admin-account resolution into one helper.

This branch is now duplicated again, and sdk/src/adminClient.ts already has several variants of privileged account selection. Centralizing it would make future hot-wallet coverage changes much harder to miss.

♻️ Refactor sketch
+ private resolveAdminAccount(): PublicKey {
+   if (this.useHotWalletAdmin || !this.isSubscribed) {
+     return this.wallet.publicKey;
+   }
+   return this.getStateAccount().admin;
+ }
...
- admin: this.useHotWalletAdmin
- 	? this.wallet.publicKey
- 	: this.isSubscribed
- 	? this.getStateAccount().admin
- 	: this.wallet.publicKey,
+ admin: this.resolveAdminAccount(),

Also applies to: 679-683

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/adminClient.ts` around lines 260 - 264, Extract the repeated ternary
that decides the admin account into a single helper method on the class (e.g.,
resolveAdminAccount or getAdminAccount) that uses this.useHotWalletAdmin,
this.wallet.publicKey, this.isSubscribed and this.getStateAccount().admin to
return the correct PublicKey; replace the inline expression (the nested ternary
currently producing admin: ...) and the duplicate at the other site with calls
to that helper; ensure the helper is used wherever privileged account selection
occurs so future hot-wallet logic changes are made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sdk/src/adminClient.ts`:
- Around line 260-264: Extract the repeated ternary that decides the admin
account into a single helper method on the class (e.g., resolveAdminAccount or
getAdminAccount) that uses this.useHotWalletAdmin, this.wallet.publicKey,
this.isSubscribed and this.getStateAccount().admin to return the correct
PublicKey; replace the inline expression (the nested ternary currently producing
admin: ...) and the duplicate at the other site with calls to that helper;
ensure the helper is used wherever privileged account selection occurs so future
hot-wallet logic changes are made in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a1ec3d14-2cac-4bff-97f2-8de86fa9a8df

📥 Commits

Reviewing files that changed from the base of the PR and between c62438d and 74fd9c3.

📒 Files selected for processing (1)
  • sdk/src/adminClient.ts

@lowkeynicc lowkeynicc merged commit 52061a0 into master Mar 26, 2026
20 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant